{#% extends 'index.html' %#}
{#% block body %#}
<style type="text/css" media="print">
body {
width: 100%;
margin: 0;
padding: 0;
}
div {
               /*height: 20px;*/
                 page-break-inside: avoid;
             }
.page-break	{ display: block; page-break-before: always; }
table.tftable {
page-break-before: always; // Always start new articles on a new page
}
table { -pdf-keep-with-next: true;}
.dontsplit {page-break-inside: avoid; }
</style>
<style type="text/css">
/*table { -pdf-keep-with-next: true;}*/
table.tftable {font-size:12px;color:#333333;width:100%;border-width: 1px;border-color: #729ea5;border-collapse: collapse;page-break-inside:avoid;}
table.tftable th {font-size:12px;font-weight:bold;border-width: 1px;padding: 8px;border-style: solid;border-color: #729ea5;text-align:left;}
/*table.tftable tr {background-color:#ffffff;}*/
table.tftable td {font-size:12px;border-width: 1px;padding: 8px;border-style: solid;border-color: #729ea5;}
</style>
<body>
    {% for dao in pageData["objects"] %}
          <table class="tftable" style="page-break-inside:avoid;">
            <tr style="page-break-inside:avoid;">
                <th colspan="5" style="font-weight: bold" text-align="left">N° {{dao.numero}} del  {{utils.dateToString(dao.data_inizio)}} -- {{dao.note|nonone}}</th>
                </tr>
                {% for riga in dao.righeprimanota %}
            <tr>
                <td width="68%"><div class="dontsplit">{{riga.denominazione|replace("\\n"," ")}}</div></td>
                {% if riga.segno =="entrata" %}
                    <td width="12%" style="color:green;"><div class="dontsplit">{{utils.mNLC(riga.valore,2)}}</div></td>
                {% elif riga.segno =="uscita" %}
                    <td width="12%" style="color:red;"><div class="dontsplit">-{{utils.mNLC(riga.valore,2)}}</div></td>
                {% endif %}
                {% if riga.tipo == "banca" %}
                    <td width="4%" style="color:blue;"><div class="dontsplit">{{(riga.tipo)}}</div></td>
                {% elif riga.tipo == "cassa" %}
                    <td width="4%" style="color:orange;"><div class="dontsplit">{{riga.tipo}}</div></td>
                {% else %}
                    <td width="4%" style="color:brown;"><div class="dontsplit">{{riga.tipo}}</div></td>
                {% endif %}
                <td width="15%"><div class="dontsplit">{{riga.banca[0:20]}}</div></td>
<!--
                <td width="6%"><div class="dontsplit">{{ riga.note_primanota|nonone }}</div></td>
-->
            </tr>
                {% endfor %}
          </table>
{% endfor %}
<div class="page-break"></div>
{% set tot = utils.calcolaTotaliPrimeNote(pageData["objects"]) %}
    <div class="col-sm-6">
        <div class="panel panel-warning">
        <div class="panel-heading">
            <h3 class="panel-title">CASSA</h3>
        </div>
        <div class="panel-body">
            <div class="col-sm-12">
                <span class="label label-success">ENTRATE</span>
                    <h4 style="display:inline;"><strong> {{utils.mNLC(tot["tot_entrate_cassa"],2)}}</strong></h4>
            </div>
            <div class="col-sm-12">
                <span class="label label-danger">USCITE</span>
                    <h4 style="display:inline;"><strong> {{utils.mNLC(tot["tot_uscite_cassa"],2)}}</strong></h4>
            </div>
            <div class="col-sm-12">
                <span class="label label-warning">SALDO</span>
                    <h4 style="display:inline;"><strong> {{utils.mNLC(tot["saldo_cassa"],2)}}</strong></h4>
            </div>
        </div>
        </div>
    </div>
    <div class="col-sm-6">
        <div class="panel panel-info">
        <div class="panel-heading">
            <h3 class="panel-title">BANCA</h3>
        </div>
        <div class="panel-body">
            <div class="col-sm-12">
                <span class="label label-success">ENTRATE</span>
                    <h4 style="display:inline;"><strong> {{utils.mNLC(tot["tot_entrate_banca"],2)}}</strong></h4>
            </div>
            <div class="col-sm-12">
                <span class="label label-danger">USCITE</span>
                    <h4 style="display:inline;"><strong> {{utils.mNLC(tot["tot_uscite_banca"],2)}}</strong></h4>
            </div>
            <div class="col-sm-12">
                <span class="label label-warning">SALDO</span>
                    <h4 style="display:inline;"><strong> {{utils.mNLC(tot["saldo_banca"],2)}}</strong></h4>
            </div>
        </div>
        </div>
    </div>
        {% for k,v in tot["tot_entrate_per_banche"].iteritems() %}
        <div class="col-sm-4">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">{{ utils.getDenominazioneBanca(k) }}</h3>
                </div>
            <div class="panel-body">
                <div class="col-sm-12">
                    <span class="label label-success">ENTRATE</span>
                        <h4 style="display:inline;"><strong> {{ utils.mNLC(v, 2) }}</strong></h4>
                </div>
                <div class="col-sm-12">
                    <span class="label label-danger">USCITE</span>
                        <h4 style="display:inline;"><strong> {{utils.mNLC(tot["tot_uscite_per_banche"][k],2)}}</strong></h4>
                </div>
                <div class="col-sm-12">
                    <span class="label label-warning">SALDO</span>
                        <h4 style="display:inline;"><strong> {{ utils.mNLC(v+(tot["tot_uscite_per_banche"][k] or 0), 2) }}</strong></h4>
                </div>
            </div>
            </div>
       </div>
        {% endfor %}
    <table class="table  table-bordered table-striped table-condensed">
        {% if utils.setconf("PrimaNota", "saldi_periodo") %}
            {% set tot_init = utils.calcolaSaldoPeriodoPrimaNota() %}
            {% if utils.getDataFiltroPrimaNota() != '' %}
                {% if tot_init["saldo_cassa"] > 0 %}
                <tr>
                    <td style="width:120px;"><b>SALDO DI CASSA DAL 01/01</b></td>
                    <td style="color:green;width:90px;text-align:right;font-size:12px"> {{utils.mNLC(tot_init["saldo_cassa"],2)}}</td>
                </tr>
                {% else %}
                <tr>
                    <td style="width:120px;"><b>SALDO DI CASSA DAL 01/01</b></td>
                    <td style="color:red;width:90px;text-align:right;font-size:12px"> {{utils.mNLC(tot_init["saldo_cassa"],2)}}</td>
                </tr>
                {% endif %}
                {% if tot_init["saldo_banca"] > 0 %}
                <tr>
                    <td style="width:120px;"><b>SALDO DI BANCA DAL 01/01</b></td>
                    <td style="color:green;width:90px;text-align:right;font-size:12px"> {{utils.mNLC(tot_init["saldo_banca"],2)}}</td>
                </tr>
                {% else %}
                <tr>
                    <td style="width:120px;"><b>SALDO DI BANCA DAL 01/01</b></td>
                    <td style="color:red;width:90px;text-align:right;font-size:12px"> {{utils.mNLC(tot_init["saldo_banca"],2)}}</td>
                </tr>
                {% endif %}
            {% endif %}
        {% endif %}
    </table>

    </div>
    </body>
{#% endblock %#}
